home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: weird behavior
- Date: 6 Feb 1996 19:53:01 GMT
- Organization: Borland International
- Message-ID: <4f8bit$i3k@druid.borland.com>
- References: <4ed10l$jap@news.csus.edu> <DM0EDv.9tF@news.arco.com>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <DM0EDv.9tF@news.arco.com>, lasbfl says...
- >
- >gustavo.sandoval@csus.edu (gustavo sandoval) wrote:
- >>I have the following linked list which I'm playing around with:
- >>
- >>class CList
- >>{
- >>public:
- >> CList();
- >> ~CList();
- >>
- >> void Insert(int element);
- >> void Print ();
- >>
- >> // Returns the number or items deleted
- >> int Delete(int target);
- >>
- >>private:
- >> CItem* head;
- >>
- >>};// CList
- >>
- >>// Implementation of the functions omitted
- >>
- >>// In main I have:
- >>
- >>void main ()
- >>{
- >> CList MyList;
- >>
- >> for (int x = 0; x < 10; x++ )
- >> MyList.Insert (x*10);
- >>
- >> MyList.Print();
- >>
- >> int count = MyList.Delete (40);
- >>
- >> MyList.Insert (50);
- >> MyList.Insert; // <== this lines
- >> MyList.Print; // <== this lines
- >>
- >> count = MyList.Delete (50);
- >>
- >>}
- >>
- >>
- >>note the lines with the arrows. The code compiles in VC 4.0 without
- warnings
- >>in level 4 or errors. When I step through those two lines the debugger just
- >>goes right by.
- >
- >Gustavo,
- >
- >You should be getting compile errors. If I have read this correctly, you have
- >two lines which consist of functions pointers. Add the '()' function
- operator,
- >and you should get your intended behaviour, although you are still missing
- >the integral argument for the Insert function.
-
- The reason for this is that Microsoft allows you to take the address of a
- member function without using &. If you're inside a member function you also
- don't need the class qualififer: it assumes that the name refers to the class
- that you're in. This, of course, is totally non-standard behavior. Last time I
- looked, MFC relied on it. That may have been fixed in MFC 4.0.
- -- Pete
-
-